<div class="page-group">
    <div class="page" data-page="book_kind">
 <!--   <header class="bar bar-nav">
        <a href="index.html" class="icon" style="width: 40%">
            <img src="img/iconfont_back@2x.png" class="back_img">
        </a>
    </header> -->
        <div class="content">
            <volist name="d" id="v">
                <div class="card demo-card-header-pic">
                    <div valign="bottom" class="card-header color-white no-border no-padding">
                        <img style="width: 100%;height: 7rem" class='card-cover' src="{$v.a_logo}" alt="" onclick="window.location.href='{:U('Activity/detail','id='.$v['activity_id'])}'">
                    </div>
                    <div class="card-content">
                        <div class="card-content-inner">
                            <div style="font-size:16px;font-weight: bold;padding: 2px">
                                <div style="float: left">{$v.title}</div>
                                <div style="padding: 2px;float: right;font-weight: normal;font-size: 14px">{:date("Y-m-d")}</div>
                            </div>
                            <div style="margin-top: 20px;padding: 2px">
                                <span style="font-size: 10px"><font color="#ee846c">报名时间：</font>{:date("Y/m/d",strtotime($v['apply_start']))}-{:date("Y/m/d",strtotime($v['apply_end']))}</span>
                                <br>
                                <span style="font-size: 10px"><font color="#ee846c">参与人数：</font>{$v.apply_total}&nbsp;&nbsp;&nbsp;剩余名额：</font>{$v.apply_num}</span>
                            </div>
                        </div>
                    </div>
                    <div class="card-footer">
                        <if condition="$v['is_apply'] eq 0">
                            <a href="{:U('Activity/detail','id='.$v['activity_id'])}" class="link">
                                <img src="__PUBLIC__/img/baoming@2x2.png" style="width: 2.9rem;"><!--未报名-->
                            </a>
                        <else/>
                            <if condition="$v['is_refund'] eq 0">
                                <a href="" class="link">
                                    <img src="__PUBLIC__/img/yibaoming@2x2.png" style="width: 2.9rem;"><!--已报名-->
                                </a>
                            <else/>
                                <a href="" class="link">
                                    <img src="__PUBLIC__/img/tuikuan.png" style="width: 2.9rem;"><!--已退款-->
                                </a>
                            </if>
                        </if>
                        <!--<font color="#DCDCDC">|</font>-->
                        <if condition="$v['is_fav'] eq 0">
                            <a href="#" class="link fav_{$v.activity_id}" onclick="join_favorite({$v.activity_id})">
                                <img src="__PUBLIC__/img/collecte@2x2.png" style="width:2.9rem"> <!--未收藏-->
                            </a>
                        <else/>
                            <a href="#" class="link fav_{$v.activity_id}" onclick="cancel_favorite({$v.activity_id})">
                                <img src="__PUBLIC__/img/collected@2x2.png" style="width:2.9rem"><!--已收藏-->
                            </a>
                        </if>
                        <!--<font color="#DCDCDC">|</font>-->
                        <!--<a href="#" class="link"><img src="__PUBLIC__/img/share@2x2.png" style="width:48px;height: 17px"></a>-->
                    </div>
                </div>
            </volist>
        </div>
        <include file="Public:footer"/>
    </div>
</div>
<script>
    //取消收藏

    function cancel_favorite($id){
        $.ajax({
            type: "GET",
            url: "{:U('Activity/cancel_fav')}",
            data: {id:$id},
            dataType: "json",
            success: function(data){
                if(data==1){
                    $.alert("已取消收藏");
                    $(".fav_"+$id+" img").attr("src","__PUBLIC__/img/collecte@2x2.png");
                    $(".fav_"+$id).attr("onclick","join_favorite("+$id+")");
                }
            }
        });
    }

    function join_favorite($id){
        $.ajax({
            type: "GET",
            url: "{:U('Activity/join_fav')}",
            data: {id:$id},
            dataType: "json",
            success: function(data){
                if(data==1){
                    $.alert("已加入收藏");
                    $(".fav_"+$id+" img").attr("src","__PUBLIC__/img/collected@2x2.png");
                    $(".fav_"+$id).attr("onclick","cancel_favorite("+$id+")");
                }
            }
        });
    }
</script>